package com.ruoyi.gzs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gzs.domain.GzsNotice;
import com.ruoyi.gzs.service.IGzsNoticeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 通知管理Controller
 * 
 * @author Liurenyi
 * @date 2022-06-29
 */
@RestController
@RequestMapping("/notice/notice")
public class GzsNoticeController extends BaseController
{
    @Autowired
    private IGzsNoticeService gzsNoticeService;

    /**
     * 查询通知管理列表
     */
    @PreAuthorize("@ss.hasPermi('notice:notice:list')")
    @GetMapping("/list")
    public TableDataInfo list(GzsNotice gzsNotice)
    {
        startPage();
        List<GzsNotice> list = gzsNoticeService.selectGzsNoticeList(gzsNotice);
        return getDataTable(list);
    }

    /**
     * 导出通知管理列表
     */
    @PreAuthorize("@ss.hasPermi('notice:notice:export')")
    @Log(title = "通知管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GzsNotice gzsNotice)
    {
        List<GzsNotice> list = gzsNoticeService.selectGzsNoticeList(gzsNotice);
        ExcelUtil<GzsNotice> util = new ExcelUtil<GzsNotice>(GzsNotice.class);
        util.exportExcel(response, list, "通知管理数据");
    }

    /**
     * 获取通知管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('notice:notice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(gzsNoticeService.selectGzsNoticeById(id));
    }

    /**
     * 新增通知管理
     */
    @PreAuthorize("@ss.hasPermi('notice:notice:add')")
    @Log(title = "通知管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GzsNotice gzsNotice)
    {
        return toAjax(gzsNoticeService.insertGzsNotice(gzsNotice));
    }

    /**
     * 修改通知管理
     */
    @PreAuthorize("@ss.hasPermi('notice:notice:edit')")
    @Log(title = "通知管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GzsNotice gzsNotice)
    {
        return toAjax(gzsNoticeService.updateGzsNotice(gzsNotice));
    }

    /**
     * 删除通知管理
     */
    @PreAuthorize("@ss.hasPermi('notice:notice:remove')")
    @Log(title = "通知管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(gzsNoticeService.deleteGzsNoticeByIds(ids));
    }
}
